package com.xiangty.ssmtemplate.common;

/**
 * @Classname Result
 * @Description 返回工具类
 * @Created by xiangty
 */
public class Result {
    // 正确返回代码
    private static final String SUCCESS_CODE = "500";
    // 错误返回代码
    private static final String ERROR_CODE = "-10000";

    // 状态代码
    private String status;
    // 信息
    private String msg;
    // 内容
    private Object data;

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Result() {}

    public Result(String status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public static Result ok(Object data) {
        return ok("OK", data);
    }

    public static Result ok(String msg, Object data) {
        return new Result(SUCCESS_CODE, msg, data);
    }

    public static Result error(Object data) {
        return error("ERROR", data);
    }

    public static Result error(String msg, Object data) {
        return new Result(ERROR_CODE, msg, data);
    }

}
